<template>
  <div
    class="card-list"
    v-for="(item, index) of listData"
    :key="index"
    @click="emit('onClick', index)"
  >
    <van-badge class="badge" :dot="item.dot">
      <div>
        <img
          class="message-icon"
          :src="item.type === 'message' ? message2 : message1"
          alt=""
        />
      </div>
    </van-badge>
    <div class="content-text">
      <div class="title">
        <span>{{ item.title }}</span>
      </div>
      <div class="describe">
        <span>{{ item.des }}</span>
      </div>
    </div>
    <div class="send-date">
      {{ item?.Date }}
      <span class="time">{{ item.time }}</span>
    </div>
  </div>
  <div class="footer-des">{{ awaitText }}</div>
</template>

<script setup lang="ts">
import message1 from '@/assets/message1.png'
import message2 from '@/assets/message2.png'
import { ListItemType } from '../init-data-types'

interface PropsType {
  listData: ListItemType[]
  awaitText: string
}

defineProps<PropsType>()
const emit = defineEmits(['onClick'])
</script>

<style scoped lang="scss">
.footer-des {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 15px;
  margin-bottom: 15px;
  font-size: 12px;
  color: #999;
}
.card-list {
  height: 69px;
  border-bottom: 0.5px #f2f2f2 solid;
  margin-left: 15.5px;
  position: relative;
  overflow: hidden;
  .send-date {
    position: absolute;
    top: 14px;
    right: 15px;
    color: #999;
    font-size: 12px;
    .time {
      padding-left: 5px;
    }
  }
  .content-text {
    width: 100%;
    position: absolute;
    left: 33.5px;
    bottom: 16px;
    overflow: hidden;
    .title {
      width: 100%;
      font-size: 16px;
      color: #333;
      width: (16px * 12);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .describe {
      width:calc(100% - 33.5px);
      height: 12px;
      line-height: 12px;
      font-size: 12px;
      margin-top: 8px;
      color: #999;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .badge {
    position: absolute;
    top: 12px;
    left: -0.5px;
    bottom: 33px;
    .message-icon {
      height: 24px;
    }
  }
}
</style>
